package Demo03.Demo04;

import java.util.Objects;

public class Account {
    //封装用户编号，账户余额两个成员变量
    private  String accountNo;
    private  double balnce;

    public Account() {
    }
    //构造器
    public Account(String accountNo, double balnce) {
        this.accountNo = accountNo;
        this.balnce = balnce;
    }
    //自动生成accountNo的getter和setter方法
    //下面两个方法根据accountNo来重写hashCode()和equal()方法
    public int hashCode(){
        return accountNo.hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Account account = (Account) o;
        return Double.compare(account.balnce, balnce) == 0 &&
                Objects.equals(accountNo, account.accountNo);
    }

    public String getAccountNo() {
        return accountNo;
    }

    public void setAccountNo(String accountNo) {
        this.accountNo = accountNo;
    }

    public double getBalnce() {
        return balnce;
    }

    public void setBalnce(double balnce) {
        this.balnce = balnce;
    }
}
